import request from '@/utils/request';

/**
 * 技师列表增加
 * @param params 查询条件
 */

export async function siteInsert(data) {
  const res = await request.post('/massage/site', data);
  if (res.data.code === 200) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 技师列表查询
 * @param params 查询条件
 */

export async function technicianList(params) {
  const res = await request.get('/api/TechnicianEnd/technician/page', {
    params
  });

  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 技师列表修改
 * @param params 查询条件
 */

export async function siteModify(data) {
  const res = await request.put('/massage/site', data);
  console.log(res);
  if (res.data.code === 200) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 技师列表查询
 * @param params 查询条件
 */

export async function technicianDetail(id) {
  const res = await request.get('/api/TechnicianEnd/technician/' + id);

  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 技师列表删除
 * @param params 查询条件
 */

export async function technicianDelete(id) {
  const res = await request.delete('/api/TechnicianEnd/technician/' + id);
  console.log(res);
  if (res.data.code === 200) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 技师列表删除
 * @param params 查询条件
 */
export async function technicianBatchDelete(data) {
  const res = await request.delete('/api/TechnicianEnd/technician/batch', {
    data
  });
  if (res.data.code === 200) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 技师列表修改审核状态
 * @param params 查询条件
 */
export async function technicianUpdate(data) {
  const res = await request.put('/api/TechnicianEnd/technician/update', data);
  if (res.data.code === 200) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 技师评论
 * @param params 查询条件
 */
export async function getByTechnicianComments(params) {
  const res = await request.get(
    '/api/TechnicianEnd/technician-evaluation/getByTechnicianComments',
    { params }
  );
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
export async function getTechnicianListHead(params) {
  const res = await request.get(
    '/api/TechnicianEnd/technician/getTechnicianListHead',
    { params }
  );
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 状态更新

// 删除评论
export async function deleteCommment(id) {
  const res = await request.delete(
    '/api/TechnicianEnd/technician-evaluation/' + id
  );
  if (res.data.code === 200) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
